<template>
	<view>
		<cu-custom :isBack="true" bgColor="bg-blue">
			<block slot="content">生产计划</block>
			<template slot="backText">
				<text class="cuIcon-back" @tap="beforePage"></text>
			</template>
		</cu-custom>
		<!-- 主题内容 -->
		<view  class="padding-t">
			<view class="public-main-info">
				<view class="u-main">
					<!-- 容器 -->
					<view class="padding2030">
						<scroll-view scroll-y="true" :style="{height: uHeight + 'px'}" @scrolltolower="lower">
							<!-- 每一列 -->
							<view class="dashed-bottom padding-tb-sm" v-for="(item, index) in planList" :key="index">
								<!-- 头部 -->
								<view class="order-info-header flex justify-between align-center" @tap="findPlanNo(item.schid)">
									<view class="">
										<text class="u-font-weight6 font-size24">计划号</text>
										<text class="u-font-weight font-size36 margin-lr-10">{{ item.schid }}</text>
										<text class="state-green padding6">{{item.state}}</text>
									</view>
									<view class="">
										<text class="cuIcon-right text-blue"></text>
									</view>
								</view>
								
								<view class="flex">
									<view class="">
										<view class="order-info-list">
											<text class="margin-right-10 u-font-weight6">计划类型</text>
											<text class="u-font-weight">{{item.planType}}</text>
										</view>
										<view class="order-info-list">
											<text class="margin-right-10 u-font-weight6">钢卷数量</text>
											<text class="u-font-weight">{{item.num}}</text>
										</view>
										<view class="order-info-list">
											<text class="margin-right-10 u-font-weight6">开始时间</text>
											<text class="u-font-weight">{{item.createtime}}</text>
										</view>
									</view>
									<view class="">
										<view class="order-info-list">
											<text class="margin-right-10 u-font-weight6">入炉炉号</text>
											<text class="u-font-weight">{{item.FceNo}}</text>
										</view>
										<view class="order-info-list">
											<text class="margin-right-10 u-font-weight6">公里数</text>
											<text class="u-font-weight">{{item.kilometers}}</text>
										</view>
										<view class="order-info-list">
											<text class="margin-right-10 u-font-weight6">下发人</text>
											<text class="u-font-weight">{{item.Issuer}}</text>
										</view>
									</view>
								</view>
							</view>
							<view class="text-center" v-show="flag">{{info}}</view>
						</scroll-view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { post } from "@/lib/Util.js";
	import {GET_PLAN_INFO} from '@/common/api/plan.js'
	export default {
		data() {
			return {
				planList: [],
				pageIndex: 1,
				pageSize: 10,
				flag: false,
				info: '正在加载中',
				uHeight: 0
			}
		},
		onLoad() {
			var len = 0
			uni.getSystemInfo({
				success: function (res) {
					len = res.windowHeight
				}
			})
			this.uHeight = len - this.CustomBar - 40 - 20
			this.getInfo()
		},
		methods: {
			beforePage() {
				uni.navigateBack({
					delta: 1
				});
			},
			findPlanNo(val) {
				if( val == '---' && val != null ) {
					return
				}
				uni.navigateTo({
					url: '/pages/modules/plan/detail?param=' + val
				})
			},
			async getInfo() {
				let res = await post(GET_PLAN_INFO, {
					page: this.pageIndex,
					size: this.pageSize
				})
				if( res.code == 0 ) {
					if(res.data.length == 0) {
						this.info = '已经到底啦'
					}else {
						this.planList = this.planList.concat(res.data)
						this.flag = false
					}
					if(this.planList.length == 0) {
						this.info = '暂无数据'
					}
				}
			},
			lower(e) {
				if (e.target.direction == "bottom") {
					this.flag = true
					this.info = '加载中……'
					++this.pageIndex
					this.getInfo()
				}
			}
		}
	}
</script>

<style>
	.order-info-header {
		height: 56upx;
		line-height: 56upx;
	}
</style>
